package com.jing.intellij.apama

import com.intellij.openapi.module.ModuleType
import com.intellij.openapi.module.ModuleTypeManager
import com.intellij.ui.JBColor
import com.intellij.ui.TextIcon
import java.awt.Font
import javax.swing.Icon

/**
 * 使用Kotlin开发的缺点, 不支持提示快捷注入到plugin.xml中
 * AllIcons.General.Balloon是一个聊天气泡图标
 * AllIcons.General.Ellipsis是一个三个点图标
 */
class ApamaModuleType: ModuleType<ApamaModuleBuilder>("APAMA_MODULE") {

    override fun createModuleBuilder(): ApamaModuleBuilder = ApamaModuleBuilder()

    override fun getName(): String = "Apama"

    override fun getDescription(): String = "This is apama project"

    override fun getNodeIcon(isOpened: Boolean): Icon {
        //margin至少4, 否则图标会不圆
        val icon = TextIcon("A", JBColor.WHITE, JBColor.BLUE, 4)
        icon.setFont(Font(Font.DIALOG, Font.PLAIN, 10))
        return icon
    }

    companion object {
        val INSTANCE: ModuleType<*> = ModuleTypeManager.getInstance().findByID("APAMA_MODULE")
    }

}